package org.lab.study.seasonal;

import org.lab.data.Quote;
import org.lab.data.Ticker;
import org.lab.study.Study;


public class LastDay extends Study{
	private float profitPercents = 0f;
	private float percentPos = 0;
	private float amount = 100;
	private int size = 0;
	
	public LastDay() {};
	
	public void run(Ticker ticker) {
				
		for (Quote quote:ticker.getQuotes()) {
			if (ticker.getDateUtil().isLastDayOfMonth(quote)) {
				float profit = ticker.getQuoteUtil().CloseToLastClosePercent(quote);
				profitPercents += profit;
				if (profit>=0) {
					percentPos++;
				}
				amount = amount * (1+profit/100);
				size++;
			}
		}
		
		profitPercents = profitPercents/size;
		
		System.out.println("Result of LastDay - Avg Profit: " + profitPercents + "%");
		
		percentPos = percentPos/size*100;
		
		System.out.println("Result of LastDay - Profit Ratio: " + percentPos + "%");
		
		System.out.println("Result of LastDay - Cumulative Profit: " + amount + "%");
	}
}
